/***************
 * Directory Users Panel
 */
AIR2.Directory.Users = function() {
    return new AIR2.UI.Panel({
        colspan: 1,
        title: 'Users',
        iconCls: 'air2-icon-user',
        showTotal: true,
        url: AIR2.HOMEURL+'/user',
        storeData: AIR2.Directory.USERS,
        tools: ['->',{
            xtype: 'air2button',
            air2type: 'CLEAR',
            iconCls: 'air2-icon-add',
            tooltip: 'New User',
            style: (AIR2.USERINFO.type == 'S') ? '' : 'display:none',
            handler: function() {
                AIR2.User.Create({
                    originEl: this.el,
                    redirect: false
                });
            }
        }],
        itemSelector: '.air2-directory-user-row',
        tpl: new Ext.XTemplate(
            '<table>' +
              '<tpl for="."><tr class="air2-directory-user-row">' +
                '<td>{[AIR2.Format.userName(values, true)]}</td>' +
              '</tr></tpl>' +
            '</table>',
            { compiled: true, disableFormats: true }
        ),
        editModal: {
            allowAdd: false,
            width: 450,
            items: {
                xtype: 'air2liveeditor',
                url: AIR2.HOMEURL+'/user',
                sortField: 'user_last_name',
                sortDir: 'ASC',
                pageSize: 50,
                hideButtons: true,
                tpl: new Ext.XTemplate(
                    '<table><tr class="air2-directory-user-row">' +
                      '<td>{user_username}</td>' +
                      '<td>{[AIR2.Format.userName(values,true)]}</td>' +
                    '</tr></table>',
                    {compiled: true, disableFormats: true}
                )
            }
        }
    });
}
